import matplotlib.pyplot as plt
import numpy as np
import scienceplots
plt.style.use(['science'])

# 创建2x2的网格
plt.figure(figsize=(4, 3))
fig1 = plt.figure(figsize=(4, 3))
plt.xlim(0, 2)
plt.ylim(0, 2)
plt.xticks(np.arange(0, 3, 1))
plt.yticks(np.arange(0, 3, 1))
plt.grid(True)

# 在网格交点处标记数字1至9
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i, x in enumerate([0, 1, 2]):
    for j, y in enumerate([0, 1, 2]):
        idx = i * 3 + j
        if idx < len(numbers):
            plt.text(x, y, str(numbers[idx]), ha='center', va='center', fontsize=12, color='red')
fig1.savefig('./wangge.png', dpi=300, format='png')

plt.show()